
export const rules = {
  address: [{ required: true, trigger: 'blur', message: '请输入门店地址' }],
  area: [{ required: true, trigger: 'blur', message: '请输入门店面积' }],
  cityCode: [{ required: true, trigger: 'change', message: '请选择城市' }],
  countyCode: [{ required: true, trigger: 'change', message: '请选择区县' }],
  managerName: [{ required: true, trigger: 'blur', message: '请输入店长姓名' }],
  managerPhone: [{ required: true, trigger: 'blur', message: '请输入店长联系电话' }],
  note: [{ required: true, trigger: 'blur', message: '请输入主营业务' }],
  noteCarBrandIds: [{ required: true, trigger: 'change', message: '请选择品牌' }],
  pid: [{ required: true, trigger: 'blur', message: '请选择上级门店' }],
  rescue: [{ required: true, trigger: 'change', message: '请选择是否道路救援' }],
  rescuePhone: [{ required: false, trigger: 'blur', message: '请输入救援电话' }],
  status: [{ required: true, trigger: 'change', message: '请选择经营状态' }],
  storeLevel: [{ required: true, trigger: 'change', message: '请选择门店等级' }],
  storeName: [{ required: true, trigger: 'blur', message: '请输入门店名称' }],
  storePhone: [{ required: true, trigger: 'blur', message: '请输入门店电话' }],
//   activeStaff: [{ required: true, trigger: 'blur', message: '请输入在职人数' }],
  manufacturer: [{ required: true, trigger: 'blur', message: '请输入厂商' }]
    //   entryTime: [
    //     { required: true, trigger: 'blur', message: '请输入入职时间' },
    //   ],
    //   loginPwd: [{ required: true, trigger: 'blur', validator: passwordCheck },],
    //   phone: [{ required: true, trigger: 'blur', validator: phoneCheck }],
    //   email: [{ required: true, trigger: 'blur', validator: emialCheck },],
    //   idcard: [{ required: true, trigger: 'blur', validator: idcardCheck }]
}
/**
 * 账号校验
 * @param {*} rule 
 * @param {*} value 
 * @param {*} callback 
 */
async function accountCheck(rule, value, callback) {
    if (value) {
        let data = await checkAccount(value);
        if (!data.success) {
            callback(data.message)
        } else {
            callback();
        }
    } else {
        callback("请输入账号名")
    }
}
function passwordCheck(rule, value, callback) {
    var regex = new RegExp(/(?=.*[0-9])(?=.*[a-zA-Z]).{8,}/);
    if (value) {
        if (regex.test(value)) {
            callback();
        } else {
            callback('密码至少8位且必须包含字母、数字')
        }
    } else {
        callback('请输入密码')
    }
}
function emialCheck(rule, value, callback) {
    var regex = new RegExp(/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
    if (value) {
        if (regex.test(value)) {
            callback();
        } else {
            callback('邮箱格式不正确')
        }
    } else {
        callback('请输入邮箱')
    }
}
function idcardCheck(rule, value, callback) {
    var regex = new RegExp(/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/);
    if (value) {
        if (regex.test(value)) {
            callback();
        } else {
            callback('身份证格式不正确')
        }
    } else {
        callback('请输入身份证')
    }
}
function phoneCheck(rule, value, callback) {
    if (value) {
        if (value.length == 11) {
            callback()
        } else {
            callback('请输入正确的手机号')
        }
    } else {
        callback('请输入手机号')
    }
}
